<?php
require_once("../phpGrid_Basic/conf.php");

$dg = new C_DataGrid("SELECT * FROM ordenes_entrega", "ID_ORDEN_ENTREGA", "ordenes_entrega");
$dg -> set_caption("Ordenes de Entrega"); 

$dg -> set_col_title("NRO_ORDEN_ENTREGA", "Orden");
$dg -> set_col_title("FECHA_RECEPCION", "Fecha Recepcion");
$dg -> set_col_title("COSTO_TOTAL_OE", "Costo");
$dg -> set_col_title("USUARIO_OPERACION", "Usuario");
$dg -> set_col_title("FECHA_OPERACION", "Fecha Operacion");

$dg->set_col_property('USUARIO_OPERACION', array('value'=>'pepe'));

$dg -> set_col_hidden("ID_ORDEN_ENTREGA",false);
$dg -> set_col_hidden("FECHA_OPERACION");

/*
$dg -> set_col_property("orderNumber", array("formoptions"=>array("rowpos"=>1,"colpos"=>1)));
$dg -> set_col_property("orderDate", array("formoptions"=>array("rowpos"=>1,"colpos"=>2)));
$dg -> set_col_property("requiredDate", array("formoptions"=>array("rowpos"=>2,"colpos"=>1)));
$dg -> set_col_property("shippedDate", array("formoptions"=>array("rowpos"=>2,"colpos"=>2)));
$dg -> set_col_property("status", array("formoptions"=>array("rowpos"=>3,"colpos"=>1)));
$dg -> set_col_property("customerNumber", array("formoptions"=>array("rowpos"=>3,"colpos"=>2)));
$dg -> set_col_property("comments", array("formoptions"=>array("rowpos"=>4,"colpos"=>1)));
*/

// enable edit
$dg->enable_edit("FORM", "CRUD");

// second grid as detail grid. Notice it is just another regular phpGrid with properites.
$sdg = new C_DataGrid("SELECT * FROM ordenes_trabajo", "ID_ORDEN_TRABAJO", "ordenes_trabajo");
$sdg -> set_col_hidden("ID_ORDEN_TRABAJO");
$sdg -> set_col_hidden("ID_ORDEN_ENTREGA");
$sdg -> set_col_hidden("DIRECCION");
$sdg -> set_col_hidden("LOCALIDAD");
$sdg -> set_col_hidden("VALLAS");
$sdg -> set_col_hidden("CANTIDAD_DIAS_VALLAS");
$sdg -> set_col_hidden("FECHA_ESTADO");
$sdg -> set_col_hidden("NRO_CERTIFICADO");
$sdg -> set_col_hidden("ID_LISTA_PRECIO");
$sdg -> set_col_hidden("FECHA_ESTADO");
$sdg -> set_col_hidden("FECHA_OPERACION");

$sdg -> set_col_title("NRO_ORDEN_TRABAJO", "Orden");
$sdg -> set_col_title("NRO_REINGRESO", "Reingreso");
$sdg -> set_col_title("TAREA", "Tarea");
$sdg -> set_col_title("ESTADO", "Estado");
$sdg -> set_col_title("COSTO_TOTAL_OT", "Costo");
$sdg -> set_col_title("COSTO_TOTAL_OT", "Costo");

$sdg -> set_col_title("USUARIO_OPERACION", "Usuario");

$sdg->enable_edit("FORM", "CRUD");

// second grid as detail grid. Notice it is just another regular phpGrid with properites.
$sdg2 = new C_DataGrid("SELECT * FROM operarios_item", array("ID_ORDEN_TRABAJO","ID_ITEM","ID_OPERARIO"), "operarios_item");
$sdg2 -> set_col_hidden("ID_ORDEN_TRABAJO");
$sdg2 -> set_col_hidden("ID_ITEM");
$sdg2 -> set_col_hidden("ID_OPERARIO");
$sdg2 -> set_col_hidden("FECHA_OPERACION");

$sdg2 -> set_col_title("ID_OPERARIO", "Operario");
$sdg2 -> set_col_title("IMPORTE", "Importe");
$sdg2 -> set_col_title("LIQUIDADO", "Liquidado");
$sdg2 -> set_col_title("USUARIO_OPERACION", "Usuario");

$sdg2->enable_edit("FORM", "CRUD");

// define master detail relationship by passing the detail grid object as the first parameter, then the foriegn key name.
// set query filter
$sdg->set_subgrid($sdg2, 'ID_ORDEN_TRABAJO');
$dg->set_subgrid($sdg, 'ID_ORDEN_ENTREGA');

$dg->display();
?>